/**
 * 获取URL指定参数
 * @param {String} name 参数名称
 * @param {String} url 目标URL地址
 * @return {String|null} 参数值
 */
export function getQueryString(name, url) {
    let _url = url || window.location.href;
    if (_url.includes("?") && _url.includes(name)) {
      let arr = _url
        .split("?")
        .filter(x => x.includes(name))
        .join()
        .split("&");
      return arr
        .find(_ => {
          return _.includes(name);
        })
        .split("=")[1];
    } else {
      return null;
    }
  }
  
  /**
   * 获取URL参数
   * @param {String} url 目标URL地址
   * @return {Object} 参数对象
   */
  export function getQueryObject(url) {
    const search = url.split("?")[1];
    if (!search) {
      return {};
    }
    return JSON.parse(
      '{"' +
        decodeURIComponent(search)
          .replace(/"/g, '\\"')
          .replace(/&/g, '","')
          .replace(/=/g, '":"') +
        '"}'
    );
  }
  